(function(){var t=BX.namespace("BX.UI.Feedback");var e=[];var i={};var n=false;t.Form=function(t){this.init(t);e.push(this)};t.Form.getList=function(){return e};t.Form.getById=function(t){return e.filter((function(e){return e.id===t}))[0]||null};t.Form.open=function(e){if(n){return}if(typeof i[e.id]!=="undefined"){i[e.id].openPanel();return}i[e.id]=new t.Form({map:e});i[e.id].openPanel()};t.Form.prototype={init:function(t){if(typeof t.map!=="undefined"){this.map=t.map;return}this.id=t.id;this.portal=t.portal;this.presets=t.presets||{};this.form=t.form||{};this.title=t.title||"";if(t.button){this.button=BX(t.button);BX.bind(this.button,"click",this.openPanel.bind(this))}},appendPresets:function(t){for(var e in t){if(!t.hasOwnProperty(e)){continue}this.presets[e]=t[e]}},openPanel:function(){n=true;BX.SidePanel.Instance.open("ui:feedback-form-"+this.id,{cacheable:false,contentCallback:function(){var t=new BX.Promise;t.fulfill();return t},animationDuration:200,events:{onLoad:this.checkSidePanelLoad.bind(this),onBeforeCloseComplete:this.checkSidePanelClosed.bind(this)},width:600})},checkSidePanelClosed:function(t){n=false},checkSidePanelLoad:function(t){if(typeof this.map!=="undefined"&&typeof this.cached==="undefined"){BX.ajax.runAction("ui.feedback.loadData",{json:{title:this.map.title||null,id:this.map.id||null,presets:this.map.presets||null,portalUri:this.map.portalUri||null,forms:this.map.forms||null,defaultForm:this.map.defaultForm||null}}).then(function(e){var i=e.data.params;this.id=i.id;this.title=i.title;this.form=i.form;this.presets=i.presets;this.portal=i.portal;this.cached=true;this.onSidePanelLoad(t)}.bind(this));return}this.onSidePanelLoad(t)},onSidePanelLoad:function(t){this.formNode=document.createElement("div");var e=document.createElement("div");e.style=`\n\t\t\t\tmargin-bottom: 25px; \n\t\t\t\tfont: 26px/26px var(--ui-font-family-primary, var(--ui-font-family-helvetica));\n\t\t\t\tcolor: var(--ui-color-text-primary);\n\t\t\t`;e.textContent=this.title;var i=t.getSlider();var n=document.createElement("div");n.style="padding: 20px; overflow-y: auto;";n.appendChild(e);n.appendChild(this.formNode);if(!i){return}i.layout.content.appendChild(n);setTimeout((function(){i.showLoader()}),0);this.loadForm(this.checkLoader.bind(this,i))},checkLoader:function(t){setTimeout((function(){t.closeLoader()}),100)},loadForm:function(t){var e=this.form;if(!e||!e.id||!e.lang||!e.sec){return}if(e.presets){this.appendPresets(e.presets)}const i="b24form"+this.id;(function(t,e,i,n){t["Bitrix24FormObject"]=n;t[n]=t[n]||function(){arguments[0].ref=i;(t[n].forms=t[n].forms||[]).push(arguments[0])};if(t[n]["forms"])return;var o=e.createElement("script");var r=1*new Date;o.async=1;o.src=i+"?"+r;var a=e.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)})(top,top.document,this.portal+"/bitrix/js/crm/form_loader.js",i);top.addEventListener("b24:form:init",(t=>{const e=t.detail.object;e.design.setFont("var(--ui-font-family-primary),var(--ui-font-family-helvetica)")}));top[i]({id:e.id,lang:e.lang,sec:e.sec,type:"inline",node:this.formNode,presets:this.presets,handlers:{load:t}})}}})();
//# sourceMappingURL=ui.feedback.form.map.js